#include"ZoomIO.h"

#include<cmath>
#include<QDebug>
#include<QWheelEvent>
#include<qgraphicsview.h>
//#include"qgraphicsview"
void zoomIn(QGraphicsView *graphicsview){
    zoom(graphicsview,1.2);
}
void zoomOut(QGraphicsView *graphicsview){
    zoom(graphicsview,0.833);
}
void zoom(QGraphicsView *graphicsview,double scaleFactor){
    //缩放函数

    qreal factor = graphicsview->transform().scale(scaleFactor,scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width();
    if (factor < 0.1 || factor > 50)
        return;
    graphicsview->scale(scaleFactor, scaleFactor);
}
void refresh(QGraphicsView *graphicsview){
    graphicsview->viewport()->update();
}
